package annotation.reflect;

public class ReflectTest {

    public static void main(String[] args) throws ClassNotFoundException {
        //通过反射机制获取类的Class对象
        Class class1 = Class.forName("annotation.reflect.User");
        System.out.println(class1);

        Class class2 = Class.forName("annotation.reflect.User");
        Class class3 = Class.forName("annotation.reflect.User");
        Class class4 = Class.forName("annotation.reflect.User");
        Class class5 = Class.forName("annotation.reflect.User");

        //一个类在内存中只有一个Class对象
        //一个类被加载后，类的整个结构都会被封装在Class对象中
        System.out.println(class1.hashCode());
        System.out.println(class2.hashCode());
        System.out.println(class3.hashCode());
        System.out.println(class4.hashCode());
        System.out.println(class5.hashCode());

        Object a = new Object();
    }
}

//实体类：pojo，entity
class User {
    private String name;
    private int id;
    private int age;

    public User() {

    }

    public User(String name, int id, int age) {
        this.name = name;
        this.id = id;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}